package com.jiang.error;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author jiangjingbo
 * @version V1.0
 * @Project java2203
 * @Package com.jiang.error
 * @Description:
 * @Date 2022/6/8 22:08
 */
public class Error implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
//        打印异常堆栈信息到日志
        e.printStackTrace();

        ModelAndView modelAndView = new ModelAndView();
// 相当于request.getSession.SetAtt...

        modelAndView.addObject("error1","抱歉页面丢失QAQ");
//跳转到页面中   hello  页面路径

        modelAndView.setViewName("error1");

        return modelAndView;
    }
}
